-
Notifications
You must be signed in to change notification settings - Fork 13.7k
fresh binding should shadow the def in expand #143141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
tests/ui/resolve/fresh-should-shallow-definitation-after-macro-expand.rs
Outdated
Show resolved
Hide resolved
tests/ui/resolve/fresh-should-shallow-definitation-after-macro-expand.rs
Outdated
Show resolved
Hide resolved
tests/ui/resolve/fresh-should-shallow-definitation-after-macro-expand.rs
Outdated
Show resolved
Hide resolved
I don't understand why this works and how it fixes the issue. |
Also "shallow" -> "shadow" in the PR/commit messages and file names. |
There may be a bug if
rust/compiler/rustc_resolve/src/ident.rs Lines 320 to 328 in 86e05cd
|
@rustbot ready |
@bvanjoi |
Are you sure this cannot successfully resolve some names that should not be resolved? I need to test this with additional cases across different rib contexts. @rustbot author |
Reminder, once the PR becomes ready for a review, use |
tests/ui/resolve/fresh-should-shadow-definitation-in-decl-macro-expand.rs
Outdated
Show resolved
Hide resolved
tests/ui/resolve/fresh-should-shadow-definitation-in-decl-macro-expand.rs
Outdated
Show resolved
Hide resolved
tests/ui/resolve/fresh-should-shadow-definitation-in-macro-expand.rs
Outdated
Show resolved
Hide resolved
tests/ui/resolve/fresh-should-shadow-definitation-in-macro-expand-in-block.rs
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
We'll definitely need a crater run and possibly a lint in the end. But at this point we probably rather need some more or less formal model of the rules that we want to achieve. #![allow(unused)]
fn f() {
let a = 0;
{
fn a() {}
{
let a = 0;
{
fn a() {}
#[macro_export]
macro_rules! mac {
() => {
let a = 0;
{
fn a() {}
{
let a = 0;
{
a; // use
}
}
}
};
}
}
}
}
}
fn main() {
let a = 0;
{
fn a() {}
{
let a = 0;
{
mac!();
}
}
}
} |
Have there been any mathematical models proposed, such as proof trees in type theory, to formally describe macro expansion? I've never encountered.😂 |
@bvanjoi |
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
I will try to answer this after reading this book. @rustbot ready |
This comment has been minimized.
This comment has been minimized.
Let's benchmark this to understand the costs. Another high level alternative to this is to just report errors for everything that cannot be resolved correctly using some single pass algorithm similar to what was used before. |
This comment has been minimized.
This comment has been minimized.
fresh binding should shadow the def in expand
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (47ce876): comparison URL. Overall result: ❌ regressions - BENCHMARK(S) FAILEDBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never ❗ ❗ ❗ ❗ ❗
❗ ❗ ❗ ❗ ❗ Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 27.0%, secondary 61.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 467.107s -> 468.456s (0.29%) |
Yeah, the current approach (or at least the current implementation) is not going to fly. |
Fixes #95237
r? @petrochenkov or @cjgillot